package com.example.test.redisson;

import org.redisson.api.RTopic;
import org.redisson.api.RedissonClient;
import org.redisson.api.listener.MessageListener;
import org.redisson.codec.SerializationCodec;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

//@Component
public class RedissonListen{

    @Autowired
    private RedissonClient redissonClient;

//    @PostConstruct
    public void redissonLiten(){
        RTopic topic = redissonClient.getTopic("dw",new SerializationCodec());
        topic.addListener(String.class, new MessageListener<String>() {
            @Override
            public void onMessage(CharSequence charSequence, String s) {
                System.out.println(s);
            }
        });
    }
}
